public class Solution {
    public String optimalDivision(int[] nums) {
        int len = nums.length;

        StringBuilder ret = new StringBuilder();

        ret.append(nums[0] + "");

        if (len == 1) {
            return ret.toString();
        } else if (len == 2) {
            ret.append("/");
            ret.append(nums[1] + "");
            return ret.toString();
        }

        for (int i = 1; i < len; i++) {
            ret.append("/");
            if (i == 1) {
                ret.append("(");
            }
            ret.append(nums[i] + "");
        }

        ret.append(")");

        return ret.toString();

    }
}
